package leetcode.dp;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author mazouri
 * @create 2021-09-20 23:55
 */
public class _123_maxProfit {
    public int maxProfit(int[] prices) {
        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 0; i < prices.length - 1; i++) {
            if (prices[i] < prices[i + 1]) {
                list.add(prices[i + 1] - prices[i]);
            }
        }

        list.sort((o1, o2) -> o2-o1);
        System.out.println(list);
        return list.get(0) + list.get(1);
    }

    public static void main(String[] args) {
        System.out.println(new _123_maxProfit().maxProfit(new int[]{1,2,3,4,5}));
    }
}
